<template>
    <div class="view_con">
        <a class="fabu_btn" v-if="userinfo&&userinfo.group_id === 2" href="#/fabu">
            <img src="/static/images/fabu.png" alt="">
            <span>我要发布</span>
        </a>
        <ul class="s_list" v-if="art.length>0">
            <li class="s_item" v-for="item in art" :key="item.id">
                <a :href="'#/ckdetail?id='+item.id+'&name=创客集市&url=#/space/cmarket'">
                    <div class="s_img">
                        <img :src="item.image" alt="">
                    </div>
                    <div class="s_info">
                        <div class="s_title">
                            <div class="title">{{item.title}}</div>
                            <div class="time">{{item.create_time}}</div>
                        </div>
                        <div class="heng1"></div>
                        <div class="des">
                            {{item.note}}
                        </div>
                        <div class="price">
                            <div class="p_title">
                                项目金额：
                            </div>
                            <div class="p_num">
                                <span>￥</span>{{item.price}}
                            </div>
                        </div>
                    </div>
                </a>
            </li>
        </ul>
        <el-empty v-else></el-empty>
    </div>
</template>

<script>
export default {
    data() {
        return {
           art:[],
            total:0,
            userinfo:null
        };
    },

    mounted() {
        this.getdata()
        this.getuserInfo()
    },

    methods: {
        getdata(){
            this.$api.post('getProList',{
                "searchKey":"",
                "sort":"sort",
                "limit":100, 
                "type":"创客集市"
            }).then(res=>{
                console.log(res)
                this.art = res.data.list
                this.total = res.data.total
            })
        },
        getuserInfo(token){
            this.$api.get('getUserInfo',{
                headers:{
                    Authorization:localStorage.getItem(token)
                }
            }).then(res=>{
                if(res.code === 200){
                    localStorage.setItem('userInfo',JSON.stringify(res.data.data))
                    this.userinfo = res.data.data
                }else{
                    alert(res.message)
                    localStorage.removeItem('token')
                    localStorage.removeItem('userInfo')
                    this.$router.push({path:'/login'})
                }
            })
        },
    },
};
</script>

<style lang="scss" scoped>
   @import  '@/assets/css/common.scss';
   
</style>